package vivace.helper;

import javax.sound.midi.MidiEvent;
import vivace.model.TimeSignature;

/**
 * A Class with information on the timesignatures in the midi track. This is helpfull for the gridhelper and timeline
 *
 */
public class TimeSignatureHelper {

	/** Numerator of the time signature */
	private int numerator;
	
	/** Denominator of the time signature */
	private int denominator;
	
	/** Position of the time signature */
	private int position;
	
	/** The event containing time signatures  */
	private MidiEvent event;
	
	/** 
	 * Constructor for TimeSignature
	 * @param numerator 	Numerator
	 * @param denominator 	Denominator
	 * @param position	 	Position of the timesignature in ticks
	 * @param event		 	MidiEvent containing the timesignature
	 */
	public TimeSignatureHelper(int numerator, int denominator, int position, MidiEvent event){
		
		this.numerator = numerator;
		this.denominator = denominator;
		this.position = position;
		this.event = event;
			
	}


    /**
     * Converts the message part of a timeSignature meta message to a TimeSignature object.
     * @param metaSignature the metaMessage containing the timeSignature.
     * @return the TimeSignature with the change of beat.
     */
    public static TimeSignature getTimeSignature(byte mm[], long resolution){
//        long resolution = Project.getPPQ();

         return new TimeSignature(mm[2],1<<mm[3], resolution );

    }
    
	/**
	 * Returns the Position of the time signature
	 * @return
	 */
	public int getPosition() {
		return position;
	}

	/**
	 * Sets the position of the time signature
	 * @param numerator
	 */
	public void setPosition(int position) {
		this.position = position;
	}
	
	/**
	 * Returns the numerator of the time signature
	 * @return
	 */
	public int getNumerator() {
		return numerator;
	}

	/**
	 * Sets the numerator of the time signature
	 * @param numerator
	 */
	public void setNumerator(int numerator) {
		this.numerator = numerator;
	}

	/**
	 * Returns the denominator of the time signature
	 * @return
	 */
	public int getDenominator() {
		return denominator;
	}

	/**
	 * Sets the denominator of the time signature
	 * @param numerator
	 */
	public void setDenominator(int denominator) {
		this.denominator = denominator;
	}

	/**
	 * Returns the event containing the time signature
	 * @return
	 */
	public MidiEvent getEvent() {
		return event;
	}

	/**
	 * Sets the event containing the time signature
	 * @param numerator
	 */
	public void setEvent(MidiEvent event) {
		this.event = event;
	}

}
